package org.example.curriculum_design_6_16.mapper;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Mapper;
import org.example.curriculum_design_6_16.entity.pojo.ResearchPaper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
* @author 郑凯
* @description 针对表【research_paper(学术论文记录表)】的数据库操作Mapper
* @createDate 2025-06-23 09:55:21
* @Entity org.example.curriculum_design_6_16.entity.pojo.ResearchPaper
*/
@Mapper
public interface ResearchPaperMapper extends BaseMapper<ResearchPaper> {
    @Insert("INSERT INTO research_paper(student_id, paper_title, publication, publish_date, paper_type, " +
            "status, contribution_rank, authors_count, score, proof_url, review_status, review_comment, academic_year) " +
            "VALUES(#{studentId}, #{paperTitle}, #{publication}, #{publishDate}, #{paperType}, #{status}, " +
            "#{contributionRank}, #{authorsCount}, #{score}, #{proofUrl}, #{reviewStatus}, #{reviewComment}, #{academicYear})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertResearchPaper(ResearchPaper paper);

    @Update("UPDATE research_paper SET " +
            "student_id=#{studentId}, paper_title=#{paperTitle}, publication=#{publication}, " +
            "publish_date=#{publishDate}, paper_type=#{paperType}, status=#{status}, " +
            "contribution_rank=#{contributionRank}, authors_count=#{authorsCount}, score=#{score}, " +
            "proof_url=#{proofUrl}, review_status=#{reviewStatus}, review_comment=#{reviewComment}, " +
            "academic_year=#{academicYear} WHERE id=#{id}")
    int updateResearchPaper(ResearchPaper paper);

    @Delete("DELETE FROM research_paper WHERE id=#{id}")
    int deleteResearchPaperById(Integer id);

    @Select("SELECT * FROM research_paper WHERE id=#{id}")
    ResearchPaper getResearchPaperById(Integer id);

    @Select("SELECT * FROM research_paper WHERE student_id=#{studentId}")
    List<ResearchPaper> getResearchPapersByStudentId(String studentId);

    @Select("SELECT * FROM research_paper WHERE student_id=#{studentId} AND academic_year=#{academicYear}")
    List<ResearchPaper> getResearchPapersByStudentIdAndYear(@Param("studentId") String studentId, @Param("academicYear") String academicYear);

    @Select("SELECT * FROM research_paper")
    List<ResearchPaper> getAllResearchPapers();

    @Update("UPDATE research_paper SET review_status=#{status}, review_comment=#{comment} WHERE id=#{id}")
    int updateReviewStatus(@Param("id") Integer id, @Param("status") String status, @Param("comment") String comment);
}




